<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QNetworkProxyQuery Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QNetworkProxyQuery Class Reference<br /><sup><sup>[<a href="qtnetwork.html">QtNetwork</a> module]</sup></sup></h1><p>The QNetworkProxyQuery class is used to query the proxy settings
for a socket <a href="#details">More...</a></p>

<h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qnetworkproxyquery.html#QueryType-enum">QueryType</a></b> { TcpSocket, UdpSocket, TcpServer, UrlRequest }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qnetworkproxyquery.html#QNetworkProxyQuery">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qnetworkproxyquery.html#QNetworkProxyQuery-2">__init__</a></b> (<i>self</i>, QUrl&#160;<i>requestUrl</i>, QueryType&#160;<i>type</i>&#160;=&#160;QNetworkProxyQuery.UrlRequest)</li><li><div class="fn" /><b><a href="qnetworkproxyquery.html#QNetworkProxyQuery-3">__init__</a></b> (<i>self</i>, QString&#160;<i>hostname</i>, int&#160;<i>port</i>, QString&#160;<i>protocolTag</i>&#160;=&#160;QString(), QueryType&#160;<i>type</i>&#160;=&#160;QNetworkProxyQuery.TcpSocket)</li><li><div class="fn" /><b><a href="qnetworkproxyquery.html#QNetworkProxyQuery-4">__init__</a></b> (<i>self</i>, int&#160;<i>bindPort</i>, QString&#160;<i>protocolTag</i>&#160;=&#160;QString(), QueryType&#160;<i>type</i>&#160;=&#160;QNetworkProxyQuery.TcpServer)</li><li><div class="fn" /><b><a href="qnetworkproxyquery.html#QNetworkProxyQuery-5">__init__</a></b> (<i>self</i>, QNetworkProxyQuery&#160;<i>other</i>)</li><li><div class="fn" />int <b><a href="qnetworkproxyquery.html#localPort">localPort</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qnetworkproxyquery.html#peerHostName">peerHostName</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qnetworkproxyquery.html#peerPort">peerPort</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qnetworkproxyquery.html#protocolTag">protocolTag</a></b> (<i>self</i>)</li><li><div class="fn" />QueryType <b><a href="qnetworkproxyquery.html#queryType">queryType</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qnetworkproxyquery.html#setLocalPort">setLocalPort</a></b> (<i>self</i>, int&#160;<i>port</i>)</li><li><div class="fn" /><b><a href="qnetworkproxyquery.html#setPeerHostName">setPeerHostName</a></b> (<i>self</i>, QString&#160;<i>hostname</i>)</li><li><div class="fn" /><b><a href="qnetworkproxyquery.html#setPeerPort">setPeerPort</a></b> (<i>self</i>, int&#160;<i>port</i>)</li><li><div class="fn" /><b><a href="qnetworkproxyquery.html#setProtocolTag">setProtocolTag</a></b> (<i>self</i>, QString&#160;<i>protocolTag</i>)</li><li><div class="fn" /><b><a href="qnetworkproxyquery.html#setQueryType">setQueryType</a></b> (<i>self</i>, QueryType&#160;<i>type</i>)</li><li><div class="fn" /><b><a href="qnetworkproxyquery.html#setUrl">setUrl</a></b> (<i>self</i>, QUrl&#160;<i>url</i>)</li><li><div class="fn" />QUrl <b><a href="qnetworkproxyquery.html#url">url</a></b> (<i>self</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />bool <b><a href="qnetworkproxyquery.html#__eq__">__eq__</a></b> (<i>self</i>, QNetworkProxyQuery&#160;<i>other</i>)</li><li><div class="fn" />bool <b><a href="qnetworkproxyquery.html#__ne__">__ne__</a></b> (<i>self</i>, QNetworkProxyQuery&#160;<i>other</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QNetworkProxyQuery class is used to query the proxy settings
for a socket</p>
<p>QNetworkProxyQuery holds the details of a socket being created
or request being made. It is used by <a href="qnetworkproxy.html">QNetworkProxy</a> and <a href="qnetworkproxyfactory.html">QNetworkProxyFactory</a> to allow
applications to have a more fine-grained control over which proxy
servers are used, depending on the details of the query. This
allows an application to apply different settings, according to the
protocol or destination hostname, for instance.</p>
<p>QNetworkProxyQuery supports the following criteria for selecting
the proxy:</p>
<ul>
<li>the type of query</li>
<li>the local port number to use</li>
<li>the destination host name</li>
<li>the destination port number</li>
<li>the protocol name, such as "http" or "ftp"</li>
<li>the URL being requested</li>
</ul>
<p>The destination host name is the host in the connection in the
case of outgoing connection sockets. It is the <tt>hostName</tt>
parameter passed to <a href="qabstractsocket.html#connectToHost">QTcpSocket.connectToHost</a>()
or the host component of a URL requested with <a href="qnetworkrequest.html">QNetworkRequest</a>.</p>
<p>The destination port number is the requested port to connect to
in the case of outgoing sockets, while the local port number is the
port the socket wishes to use locally before attempting the
external connection. In most cases, the local port number is used
by listening sockets only (<a href="qtcpsocket.html">QTcpSocket</a>) or by datagram sockets (<a href="qudpsocket.html">QUdpSocket</a>).</p>
<p>The protocol name is an arbitrary string that indicates the type
of connection being attempted. For example, it can match the scheme
of a URL, like "http", "https" and "ftp". In most cases, the proxy
selection will not change depending on the protocol, but this
information is provided in case a better choice can be made, like
choosing an caching HTTP proxy for HTTP-based connections, but a
more powerful SOCKSv5 proxy for all others.</p>
<p>The network configuration specifies which configuration to use,
when bearer management is used. For example on a mobile phone the
proxy settings are likely to be different for the cellular network
vs WLAN.</p>
<p>Some of the criteria may not make sense in all of the types of
query. The following table lists the criteria that are most
commonly used, according to the type of query.</p>
<table class="generic">
<thead>
<tr class="qt-style">
<th>Query type</th>
<th>Description</th>
</tr>
</thead>
<tr class="odd" valign="top">
<td><a href="qnetworkproxyquery.html#QueryType-enum">TcpSocket</a></td>
<td>Normal sockets requesting a connection to a remote server, like
<a href="qtcpsocket.html">QTcpSocket</a>. The peer hostname and
peer port match the values passed to <a href="qabstractsocket.html#connectToHost">QTcpSocket.connectToHost</a>().
The local port is usually -1, indicating the socket has no
preference in which port should be used. The URL component is not
used.</td>
</tr>
<tr class="even" valign="top">
<td><a href="qnetworkproxyquery.html#QueryType-enum">UdpSocket</a></td>
<td>Datagram-based sockets, which can both send and receive. The
local port, remote host or remote port fields can all be used or be
left unused, depending on the characteristics of the socket. The
URL component is not used.</td>
</tr>
<tr class="odd" valign="top">
<td><a href="qnetworkproxyquery.html#QueryType-enum">TcpServer</a></td>
<td>Passive server sockets that listen on a port and await incoming
connections from the network. Normally, only the local port is
used, but the remote address could be used in specific
circumstances, for example to indicate which remote host a
connection is expected from. The URL component is not used.</td>
</tr>
<tr class="even" valign="top">
<td><a href="qnetworkproxyquery.html#QueryType-enum">UrlRequest</a></td>
<td>A more high-level request, such as those coming from <a href="qnetworkaccessmanager.html">QNetworkAccessManager</a>. These
requests will inevitably use an outgoing TCP socket, but the this
query type is provided to indicate that more detailed information
is present in the URL component. For ease of implementation, the
URL's host and port are set as the destination address.</td>
</tr>
</table>
<p>It should be noted that any of the criteria may be missing or
unknown (an empty <a href="qstring.html">QString</a> for the
hostname or protocol name, -1 for the port numbers). If that
happens, the functions executing the query should make their best
guess or apply some implementation-defined default values.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="QueryType-enum" />QNetworkProxyQuery.QueryType</h3><p>Describes the type of one <a href="qnetworkproxyquery.html">QNetworkProxyQuery</a> query.</p>
<table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QNetworkProxyQuery.TcpSocket</tt></td>
<td class="topAlign"><tt>0</tt></td>
<td class="topAlign">a normal, outgoing TCP socket</td>
</tr>
<tr>
<td class="topAlign"><tt>QNetworkProxyQuery.UdpSocket</tt></td>
<td class="topAlign"><tt>1</tt></td>
<td class="topAlign">a datagram-based UDP socket, which could send
to multiple destinations</td>
</tr>
<tr>
<td class="topAlign"><tt>QNetworkProxyQuery.TcpServer</tt></td>
<td class="topAlign"><tt>100</tt></td>
<td class="topAlign">a TCP server that listens for incoming
connections from the network</td>
</tr>
<tr>
<td class="topAlign"><tt>QNetworkProxyQuery.UrlRequest</tt></td>
<td class="topAlign"><tt>101</tt></td>
<td class="topAlign">a more complex request which involves loading
of a URL</td>
</tr>
</table>
<p><b>See also</b> <a href="qnetworkproxyquery.html#queryType">queryType</a>() and <a href="qnetworkproxyquery.html#setQueryType">setQueryType</a>().</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QNetworkProxyQuery" />QNetworkProxyQuery.__init__ (<i>self</i>)</h3><p>Constructs a default <a href="qnetworkproxyquery.html">QNetworkProxyQuery</a> object. By
default, the query type will be <a href="qnetworkproxyquery.html#QueryType-enum">QNetworkProxyQuery.TcpSocket</a>.</p>


<h3 class="fn"><a name="QNetworkProxyQuery-2" />QNetworkProxyQuery.__init__ (<i>self</i>, <a href="qurl.html">QUrl</a>&#160;<i>requestUrl</i>, <a href="qnetworkproxyquery.html#QueryType-enum">QueryType</a>&#160;<i>type</i>&#160;=&#160;QNetworkProxyQuery.UrlRequest)</h3><p>Constructs a <a href="qnetworkproxyquery.html">QNetworkProxyQuery</a> with the URL
<i>requestUrl</i> and sets the query type to <i>queryType</i>.</p>
<p><b>See also</b> <a href="qnetworkproxyquery.html#protocolTag">protocolTag</a>(), <a href="qnetworkproxyquery.html#peerHostName">peerHostName</a>(), and
<a href="qnetworkproxyquery.html#peerPort">peerPort</a>().</p>


<h3 class="fn"><a name="QNetworkProxyQuery-3" />QNetworkProxyQuery.__init__ (<i>self</i>, QString&#160;<i>hostname</i>, int&#160;<i>port</i>, QString&#160;<i>protocolTag</i>&#160;=&#160;QString(), <a href="qnetworkproxyquery.html#QueryType-enum">QueryType</a>&#160;<i>type</i>&#160;=&#160;QNetworkProxyQuery.TcpSocket)</h3><p>Constructs a <a href="qnetworkproxyquery.html">QNetworkProxyQuery</a> of type
<i>queryType</i> and sets the protocol tag to be
<i>protocolTag</i>. This constructor is suitable for <a href="qnetworkproxyquery.html#QueryType-enum">QNetworkProxyQuery.TcpSocket</a>
queries, because it sets the peer hostname to <i>hostname</i> and
the peer's port number to <i>port</i>.</p>


<h3 class="fn"><a name="QNetworkProxyQuery-4" />QNetworkProxyQuery.__init__ (<i>self</i>, int&#160;<i>bindPort</i>, QString&#160;<i>protocolTag</i>&#160;=&#160;QString(), <a href="qnetworkproxyquery.html#QueryType-enum">QueryType</a>&#160;<i>type</i>&#160;=&#160;QNetworkProxyQuery.TcpServer)</h3><p>Constructs a <a href="qnetworkproxyquery.html">QNetworkProxyQuery</a> of type
<i>queryType</i> and sets the protocol tag to be
<i>protocolTag</i>. This constructor is suitable for <a href="qnetworkproxyquery.html#QueryType-enum">QNetworkProxyQuery.TcpSocket</a>
queries because it sets the local port number to
<i>bindPort</i>.</p>
<p>Note that <i>bindPort</i> is of type quint16 to indicate the
exact port number that is requested. The value of -1 (unknown) is
not allowed in this context.</p>
<p><b>See also</b> <a href="qnetworkproxyquery.html#localPort">localPort</a>().</p>


<h3 class="fn"><a name="QNetworkProxyQuery-5" />QNetworkProxyQuery.__init__ (<i>self</i>, <a href="qnetworkproxyquery.html">QNetworkProxyQuery</a>&#160;<i>other</i>)</h3><p>Constructs a <a href="qnetworkproxyquery.html">QNetworkProxyQuery</a> object that is a
copy of <i>other</i>.</p>


<h3 class="fn"><a name="localPort" />int QNetworkProxyQuery.localPort (<i>self</i>)</h3><p>Returns the port number of the socket that will accept incoming
packets from remote servers or -1 if the port is not known.</p>
<p><b>See also</b> <a href="qnetworkproxyquery.html#peerPort">peerPort</a>(), <a href="qnetworkproxyquery.html#peerHostName">peerHostName</a>(), and
<a href="qnetworkproxyquery.html#setLocalPort">setLocalPort</a>().</p>


<h3 class="fn"><a name="peerHostName" />QString QNetworkProxyQuery.peerHostName (<i>self</i>)</h3><p>Returns the host name or IP address being of the outgoing
connection being requested, or an empty string if the remote
hostname is not known.</p>
<p>If the query type is <a href="qnetworkproxyquery.html#QueryType-enum">QNetworkProxyQuery.UrlRequest</a>,
this function returns the host component of the URL being
requested.</p>
<p><b>See also</b> <a href="qnetworkproxyquery.html#peerPort">peerPort</a>(), <a href="qnetworkproxyquery.html#localPort">localPort</a>(), and <a href="qnetworkproxyquery.html#setPeerHostName">setPeerHostName</a>().</p>


<h3 class="fn"><a name="peerPort" />int QNetworkProxyQuery.peerPort (<i>self</i>)</h3><p>Returns the port number for the outgoing request or -1 if the
port number is not known.</p>
<p>If the query type is <a href="qnetworkproxyquery.html#QueryType-enum">QNetworkProxyQuery.UrlRequest</a>,
this function returns the port number of the URL being requested.
In general, frameworks will fill in the port number from their
default values.</p>
<p><b>See also</b> <a href="qnetworkproxyquery.html#peerHostName">peerHostName</a>(), <a href="qnetworkproxyquery.html#localPort">localPort</a>(), and <a href="qnetworkproxyquery.html#setPeerPort">setPeerPort</a>().</p>


<h3 class="fn"><a name="protocolTag" />QString QNetworkProxyQuery.protocolTag (<i>self</i>)</h3><p>Returns the protocol tag for this <a href="qnetworkproxyquery.html">QNetworkProxyQuery</a> object, or an
empty <a href="qstring.html">QString</a> in case the protocol tag
is unknown.</p>
<p>In the case of queries of type <a href="qnetworkproxyquery.html#QueryType-enum">QNetworkProxyQuery.UrlRequest</a>,
this function returns the value of the scheme component of the
URL.</p>
<p><b>See also</b> <a href="qnetworkproxyquery.html#setProtocolTag">setProtocolTag</a>() and
<a href="qnetworkproxyquery.html#url">url</a>().</p>


<h3 class="fn"><a name="queryType" /><a href="qnetworkproxyquery.html#QueryType-enum">QueryType</a> QNetworkProxyQuery.queryType (<i>self</i>)</h3><p>Returns the query type.</p>
<p><b>See also</b> <a href="qnetworkproxyquery.html#setQueryType">setQueryType</a>().</p>


<h3 class="fn"><a name="setLocalPort" />QNetworkProxyQuery.setLocalPort (<i>self</i>, int&#160;<i>port</i>)</h3><p>Sets the port number that the socket wishes to use locally to
accept incoming packets from remote servers to <i>port</i>. The
local port is most often used with the <a href="qnetworkproxyquery.html#QueryType-enum">QNetworkProxyQuery.TcpServer</a>
and <a href="qnetworkproxyquery.html#QueryType-enum">QNetworkProxyQuery.UdpSocket</a>
query types.</p>
<p>Valid values are 0 to 65535 (with 0 indicating that any port
number will be acceptable) or -1, which means the local port number
is unknown or not applicable.</p>
<p>In some circumstances, for special protocols, it's the local
port number can also be used with a query of type <a href="qnetworkproxyquery.html#QueryType-enum">QNetworkProxyQuery.TcpSocket</a>.
When that happens, the socket is indicating it wishes to use the
port number <i>port</i> when connecting to a remote host.</p>
<p><b>See also</b> <a href="qnetworkproxyquery.html#localPort">localPort</a>(), <a href="qnetworkproxyquery.html#setPeerPort">setPeerPort</a>(), and
<a href="qnetworkproxyquery.html#setPeerHostName">setPeerHostName</a>().</p>


<h3 class="fn"><a name="setPeerHostName" />QNetworkProxyQuery.setPeerHostName (<i>self</i>, QString&#160;<i>hostname</i>)</h3><p>Sets the hostname of the outgoing connection being requested to
<i>hostname</i>. An empty hostname can be used to indicate that the
remote host is unknown.</p>
<p>The peer host name can also be used to indicate the expected
source address of an incoming connection in the case of <a href="qnetworkproxyquery.html#QueryType-enum">QNetworkProxyQuery.UdpSocket</a>
or <a href="qnetworkproxyquery.html#QueryType-enum">QNetworkProxyQuery.TcpServer</a>
query types.</p>
<p><b>See also</b> <a href="qnetworkproxyquery.html#peerHostName">peerHostName</a>(), <a href="qnetworkproxyquery.html#setPeerPort">setPeerPort</a>(), and
<a href="qnetworkproxyquery.html#setLocalPort">setLocalPort</a>().</p>


<h3 class="fn"><a name="setPeerPort" />QNetworkProxyQuery.setPeerPort (<i>self</i>, int&#160;<i>port</i>)</h3><p>Sets the requested port number for the outgoing connection to be
<i>port</i>. Valid values are 1 to 65535, or -1 to indicate that
the remote port number is unknown.</p>
<p>The peer port number can also be used to indicate the expected
port number of an incoming connection in the case of <a href="qnetworkproxyquery.html#QueryType-enum">QNetworkProxyQuery.UdpSocket</a>
or <a href="qnetworkproxyquery.html#QueryType-enum">QNetworkProxyQuery.TcpServer</a>
query types.</p>
<p><b>See also</b> <a href="qnetworkproxyquery.html#peerPort">peerPort</a>(), <a href="qnetworkproxyquery.html#setPeerHostName">setPeerHostName</a>(),
and <a href="qnetworkproxyquery.html#setLocalPort">setLocalPort</a>().</p>


<h3 class="fn"><a name="setProtocolTag" />QNetworkProxyQuery.setProtocolTag (<i>self</i>, QString&#160;<i>protocolTag</i>)</h3><p>Sets the protocol tag for this <a href="qnetworkproxyquery.html">QNetworkProxyQuery</a> object to be
<i>protocolTag</i>.</p>
<p>The protocol tag is an arbitrary string that indicates which
protocol is being talked over the socket, such as "http", "xmpp",
"telnet", etc. The protocol tag is used by the backend to return a
request that is more specific to the protocol in question: for
example, a HTTP connection could be use a caching HTTP proxy
server, while all other connections use a more powerful SOCKSv5
proxy server.</p>
<p><b>See also</b> <a href="qnetworkproxyquery.html#protocolTag">protocolTag</a>().</p>


<h3 class="fn"><a name="setQueryType" />QNetworkProxyQuery.setQueryType (<i>self</i>, <a href="qnetworkproxyquery.html#QueryType-enum">QueryType</a>&#160;<i>type</i>)</h3><p>Sets the query type of this object to be <i>type</i>.</p>
<p><b>See also</b> <a href="qnetworkproxyquery.html#queryType">queryType</a>().</p>


<h3 class="fn"><a name="setUrl" />QNetworkProxyQuery.setUrl (<i>self</i>, <a href="qurl.html">QUrl</a>&#160;<i>url</i>)</h3><p>Sets the URL component of this <a href="qnetworkproxyquery.html">QNetworkProxyQuery</a> object to be
<i>url</i>. Setting the URL will also set the protocol tag, the
remote host name and port number. This is done so as to facilitate
the implementation of the code that determines the proxy server to
be used.</p>
<p><b>See also</b> <a href="qnetworkproxyquery.html#url">url</a>(),
<a href="qnetworkproxyquery.html#peerHostName">peerHostName</a>(),
and <a href="qnetworkproxyquery.html#peerPort">peerPort</a>().</p>


<h3 class="fn"><a name="url" /><a href="qurl.html">QUrl</a> QNetworkProxyQuery.url (<i>self</i>)</h3><p>Returns the URL component of this <a href="qnetworkproxyquery.html">QNetworkProxyQuery</a> object in case of
a query of type <a href="qnetworkproxyquery.html#QueryType-enum">QNetworkProxyQuery.UrlRequest</a>.</p>
<p><b>See also</b> <a href="qnetworkproxyquery.html#setUrl">setUrl</a>().</p>


<h3 class="fn"><a name="__eq__" />bool QNetworkProxyQuery.__eq__ (<i>self</i>, <a href="qnetworkproxyquery.html">QNetworkProxyQuery</a>&#160;<i>other</i>)</h3><h3 class="fn"><a name="__ne__" />bool QNetworkProxyQuery.__ne__ (<i>self</i>, <a href="qnetworkproxyquery.html">QNetworkProxyQuery</a>&#160;<i>other</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.9.1 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2011</td><td align="right" width="25%">Qt&#160;4.8.0</td></tr></table></div></address></body></html>